package com.zj.leetcode.easy;

/**
 * @program: algorithm
 * @description: 移除元素
 * 27 remove-element
 * @author: Zhang Bo
 * @create: 2022-10-18 21:15:30
 **/
public class RemoveElement {
    public static void main(String[] args) {
        RemoveElement.Solution solution = new RemoveElement.Solution();

        System.out.println(solution.removeElement(new int[]{3, 2, 2, 3, 1, 3}, 3));
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    static class Solution {
        public int removeElement(int[] nums, int val) {
            int i = 0;
            int j = 0;
            int count = 0;
            while (j < nums.length) {
                while (j < nums.length && nums[j] == val) {
                    j++;
                    count++;
                }
                nums[i] = nums[j];

                i++;
                j++;
            }
            return i;

        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}